package com.jyhz.author.service.controller;

import com.jyhz.author.common.pojo.UserInfo;
import com.jyhz.author.common.utils.JwtUtils;
import com.jyhz.author.service.config.JwtProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author:谢君臣
 * @Date:2021/7/12-18:14
 * @version:1.0
 * @function:
 */
@Controller
public class JwtPropertiesController {

    @Autowired
    private JwtProperties jwtProperties;

    @GetMapping("/jwtProperties")
    public UserInfo jwtProperties(@RequestParam("token")String token){
        UserInfo user = null;
        try {
            user = JwtUtils.getInfoFromToken(token, jwtProperties.getPublicKey());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return user;
    }
}
